use "hierarchy_replication.dta", clear

**Table A.1


sutex wi_v2stfisccap2 Fmax_civilwar1  wi_usa_median   wi_v2xcl_prpty  wi_lnpop_wdi wi_lngdppc ///
 wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs  coldwar  ///
, minmax labels


**Table A.2   \\\\ this isn't consistent

xtsum Fmax_civilwar1 

reg Fmax_civilwar1  wi_Fmax_civilwar1
display e(r2)

reg Fmax_civilwar1  btw_Fmax_civilwar1
display e(r2)




**Figure B.1 (See R code)




**Table B.3

global cntrl wi_compete  wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
global cwcntrl wi_lnpop_wdi btw_Fmax_civilwar1 wi_lngdppc wi_compete wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar

cap gen uspr = wi_v2xcl_prpty* wi_usa_median
cap gen uscap= wi_usa_median*wi_v2stfisccap2 
cap gen ussq= wi_usa_median*wi_usa_median 

reg F.wi_v2stfisccap2 wi_v2xcl_prpty  wi_usa_median  uspr  $cntrl 
 estimates store m1
 
 logit Fmax_civilwar1  wi_usa_median wi_v2stfisccap2 uscap $cwcntrl 
 estimates store b2

 reg wi_v2xcl_prpty  wi_usa_median  ussq $cntrl 
 estimates store m3a 
 
reg F.wi_v2stfisccap2 wi_v2xcl_prpty  wi_usa_median  ussq $cntrl 
 estimates store m3
 
lab var uspr "U.S. Support * PR"
lab var uscap "U.S. Support * Capacity"
lab var ussq "U.S. Support$^2$"


estout m1 b2 m3a m3 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median  uspr uscap ussq wi_v2xcl_prpty wi_v2stfisccap2) ///
 drop(wi_lnpop_wdi btw_Fmax_civilwar1 wi_lngdppc wi_compete wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar) ///
mlabels ("Model 1" "Model 2" "Model 3" ) ///
title("")
 
 **Indirect Effects with interactions (not shown)
  paramed wi_Fv2stfisccap2 , avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
cvars($cntrl)  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) 


**Figure B.2 

 
reg F.wi_v2stfisccap2   c.wi_usa_median##c.wi_usa_median $cntrl  , robust
	margins, at(wi_usa_median = (-1(.1)1) )
	marginsplot, scheme(s1mono) name(nonlinear, replace) yline(0) title(Fiscal Capacity)

reg wi_v2xcl_prpty   c.wi_usa_median##c.wi_usa_median $cntrl  , robust
	estimates store m2
	margins, at(wi_usa_median = (-1(.1)1) )
	marginsplot, scheme(s1mono) name(nonlinear2, replace) yline(0)  title(Property Rights)

	graph combine nonlinear nonlinear2, scheme(s1mono)


**Table C.4 & C.5
  **Time trends
reg F.wi_v2stfisccap2   wi_usa_median   wi_v2xcl_prpty  ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar timetrend*
 estimates store m1t
 
  
     reg wi_v2xcl_prpty  wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar timetrend*
 estimates store m7t
 
   paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars(wi_onset1 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar timetrend* )  a0(0)  a1(.40) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med1t
 
  **Year fixed effects
  cap drop yr_*
 tab year, g(yr_)
 reg F.wi_v2stfisccap2   wi_usa_median   wi_v2xcl_prpty  ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar yr_*
 estimates store m1f
 
  
     reg wi_v2xcl_prpty  wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar yr_*
 estimates store m7f
 
   paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars(wi_onset1 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar yr_* )  a0(0)  a1(.40) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med1f
 
 
 **Lagged DVs
  reg F.wi_v2stfisccap2  wi_v2stfisccap2  wi_usa_median   wi_v2xcl_prpty  ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m1l
 
  
     reg wi_v2xcl_prpty  l.wi_v2xcl_prpty  wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m7l
 
   paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars(wi_onset1 wi_v2stfisccap2 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar  )  a0(0)  a1(.40) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med1l
 
lab var timetrend "Trend"
lab var timetrend2 "Trend$^2$"
lab var timetrend3 "Trend$^3$"
lab var timetrend4 "Trend$^4$"
 
      estout m7t m1t m7f m1f m7l m1l , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median wi_v2xcl_prpty ) drop(yr_* wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")


***NOT SURE WHAT TABLE THIS IS**** Delete???
estout m1 b2 m3a m3 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median  uspr uscap ussq wi_v2xcl_prpty wi_v2stfisccap2) ///
 drop(wi_lnpop_wdi btw_Fmax_civilwar1 wi_lngdppc wi_compete wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar) ///
mlabels ("Model 1" "Model 2" "Model 3" ) ///
title("")



*** Figure D.1 - Exclusion Restriction Sensitivity

/// Conley et al sensitivity test: 
plausexog uci F.wi_v2stfisccap2  $cntrl 	///
	 (wi_usa_median=echelon) 	if sample == 1 ///
		, gmin(0)	///
            gmax(0.1)  vce(robust) grid(5)	///
			graph(wi_usa_median) graphdelta(0 0.05 0.2) yline(0)	///
			legend(position(6) col(2) label(1 "Upper Bound") label(2 "Lower Bound"))	///
			xtitle("Delta")	ytitle(Beta of Fiscal Capacity) scheme(s1mono) name(pe1, replace)

plausexog uci Fwi_v2xcl_prpty  $cntrl 	///
	 (wi_usa_median=echelon) 	if sample == 1 ///
		, gmin(0)	///
            gmax(0.1)  vce(robust) grid(5)	///
			graph(wi_usa_median) graphdelta(0 0.05 0.2) yline(0)	///
			legend(position(6) col(2) label(1 "Upper Bound") label(2 "Lower Bound"))	///
			xtitle("Delta")	ytitle(Beta of Property Rights) scheme(s1mono) name(pe2, replace)
	
graph combine pe1 pe2, scheme(s1mono) 




*** Table E.6 - Long Run Effects 
use hierarchy_replication.dta, clear
est clear 
 
xtset ccode year 

gen L5wi_usa_median=L5.wi_usa_median
lab var L5wi_usa_median " $US Support_(t-5)$ " 


global cntrl wi_compete  wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 

reg F.wi_v2stfisccap2   L5wi_usa_median $cntrl  , robust
 estimates store m1
 cap drop sample
 gen sample =1 if e(sample)
 
reg wi_v2xcl_prpty   L5wi_usa_median $cntrl  if sample==1 , robust
 estimates store m2
  
reg F.wi_v2stfisccap2 wi_v2xcl_prpty L5wi_usa_median $cntrl if sample==1 , robust
 estimates store m3


// estimation of the mediation effect.  
// Add this parameter to the table by hand
paramed wi_Fv2stfisccap2 , avar(L5wi_usa_median) mvar(wi_v2xcl_prpty ) ///
cvars($cntrl)  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med1

 
ivreg2 Fwi_v2stfisccap2 $cntrl ///
 (L5wi_usa_median=L5.echelon),  gmm2s  first 
  estimates store iv1
weakivtest
 
ivreg2 Fwi_v2xcl_prpty  $cntrl ///
 (L5wi_usa_median=L5.echelon) if sample==1, gmm2s first 
  estimates store iv2 
 weakivtest

estout m1 m2 m3 iv1 iv2 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(L5wi_usa_median wi_v2xcl_prpty ) drop(wi_c2 wi_c3) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" ) ///
title("") 


**Table F.7 major Power support
use hierarchy_replication.dta, clear
est clear 

sort ccode year
foreach var of varlist  uk_median fr_median {
by ccode: egen btw_`var' = mean(`var') 
gen wi_`var' = `var' - btw_`var' if `var'!=.
}


 **Russian Support 
 reg F.wi_v2stfisccap2  wi_usa_median wi_rus_median   wi_v2xcl_prpty  ///
 $cntrl
   estimates store rus1
 
      reg wi_v2xcl_prpty  wi_usa_median  wi_rus_median    ///
 $cntrl
 estimates store rus2
  
 logit Fmax_civilwar1  wi_usa_median wi_rus_median  wi_v2stfisccap2 wi_v2xcl_prpt  btw_Fmax_civilwar1 ///
   $cntrl
  estimates store rus3
  
  
 *China Support
 reg F.wi_v2stfisccap2  wi_usa_median wi_chi_median   wi_v2xcl_prpty  ///
 $cntrl
   estimates store chi1
 
        reg wi_v2xcl_prpty  wi_usa_median wi_chi_median  ///
 $cntrl
   estimates store chi2

  
 logit Fmax_civilwar1  wi_usa_median wi_chi_median  wi_v2stfisccap2 wi_v2xcl_prpt btw_Fmax_civilwar1 ///
 $cntrl 
  estimates store chi3
  
  
  *France Support
   reg F.wi_v2stfisccap2  wi_usa_median wi_fr_median   wi_v2xcl_prpty  ///
 $cntrl
   estimates store fr1
 
        reg wi_v2xcl_prpty  wi_usa_median wi_fr_median   ///
 $cntrl
   estimates store fr2

 logit Fmax_civilwar1  wi_usa_median wi_fr_median  wi_v2stfisccap2 wi_v2xcl_prpt btw_Fmax_civilwar1 ///
 $cntrl  
   estimates store fr3
  
  
  *UK Support
  
     reg F.wi_v2stfisccap2  wi_usa_median wi_uk_median   wi_v2xcl_prpty  ///
 $cntrl
   estimates store uk1
   
       reg wi_v2xcl_prpty  wi_usa_median wi_uk_median   ///
 $cntrl
   estimates store uk2

  
 logit Fmax_civilwar1  wi_usa_median wi_uk_median  wi_v2stfisccap2 wi_v2xcl_prpt btw_Fmax_civilwar1 ///
 $cntrl  
   estimates store uk3
   
   lab var wi_rus_median "Russia Support"
   lab var wi_chi_median "China Support"
   lab var wi_fr_median "France Support"
   lab var wi_uk_median "UK Support"
   
         estout rus2 rus1 chi2 chi1 fr2 fr1 uk2 uk1 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median wi_rus_median wi_chi_median  wi_fr_median wi_uk_median wi_v2xcl_prpty) drop( $cntrl) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")
 

     paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_rus_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 

     paramed wi_Fv2stfisccap2, avar( wi_rus_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_usa_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 


     paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars(wi_chi_median $cntrl ) a0(0)  a1(1) m(0) ///
 yreg(linear) mreg(linear) nointeraction 

     paramed wi_Fv2stfisccap2, avar( wi_chi_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_usa_median  $cntrl)  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 


     paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_fr_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 

     paramed wi_Fv2stfisccap2, avar( wi_fr_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_usa_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 

     paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_uk_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 

     paramed wi_Fv2stfisccap2, avar( wi_uk_median) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_usa_median $cntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 


**Table G.8 Foreign Aid Mediation Analysis

reg F.wi_v2stfisccap2  wi_USaidnet  wi_EUnet  wi_v2xcl_prpty  ///
 $cntrl
   estimates store US1
 
reg wi_v2xcl_prpty  wi_USaidnet  wi_EUnet ///
 $cntrl 
 estimates store US2


reg Fmax_civilwar1   wi_USaid  wi_EUnet wi_v2stfisccap2 wi_v2xcl_prpt  btw_Fmax_civilwar1 ///
   $cntrl
  estimates store US3
 
 
paramed wi_Fv2stfisccap2, avar(wi_USaid) mvar(wi_v2xcl_prpty ) ///
	cvars( wi_EUnet $cntrl )  a0(0)  a1(1) m(0) ///
	yreg(linear) mreg(linear) nointeraction 
 
paramed wi_Fv2stfisccap2, avar(wi_EUnet ) mvar(wi_v2xcl_prpty ) ///
	cvars(wi_USaid  $cntrl )  a0(0)  a1(1) m(0) ///
	yreg(linear) mreg(linear) nointeraction 
  
 

 reg F.wi_v2stfisccap2  wi_usa_median wi_EUnet   wi_v2xcl_prpty  ///
	$cntrl
  estimates store EU1
 
 reg wi_v2xcl_prpty  wi_usa_median  wi_EUnet   ///
	$cntrl 
	estimates store EU2
  
reg Fmax_civilwar1   wi_usa_median  wi_EUnet  wi_v2stfisccap2 wi_v2xcl_prpt  btw_Fmax_civilwar1 ///
   $cntrl

estimates store EU3

paramed wi_Fv2stfisccap2, avar(wi_usa_median) mvar(wi_v2xcl_prpty ) ///
	cvars( wi_EUnet $cntrl )  a0(0)  a1(1) m(0) ///
	yreg(linear) mreg(linear) nointeraction 

paramed wi_Fv2stfisccap2, avar(wi_EUnet) mvar(wi_v2xcl_prpty ) ///
	cvars(wi_usa_median $cntrl)  a0(0)  a1(1) m(0) ///
	yreg(linear) mreg(linear) nointeraction 

  suest US1 US2 US3 
  
*Indirect effect of US AID
nlcom [US2_mean]_b[wi_USaidnet]*[US3_mean ]_b[wi_v2xcl_prpty] + [US1_mean]_b[wi_USaidnet]*[US3_mean ]_b[wi_v2stfisccap2]
*Indirect effect of EU AID
nlcom [US2_mean]_b[wi_EUnet]*[US3_mean ]_b[wi_v2xcl_prpty] + [US1_mean]_b[wi_EUnet]*[US3_mean ]_b[wi_v2stfisccap2]
  
suest EU1 EU2 EU3 
  
*Indirect effect of EU Aid
nlcom [EU2_mean]_b[wi_EUnet]*[EU3_mean]_b[wi_v2xcl_prpty] + [EU1_mean]_b[wi_EUnet ]*[EU3_mean]_b[wi_v2stfisccap2]
  
*Indirect effect of US Support

nlcom [EU2_mean]_b[wi_usa_median]*[EU3_mean]_b[wi_v2xcl_prpty] + [EU1_mean]_b[wi_usa_median]*[EU3_mean]_b[wi_v2stfisccap2]
  
lab var wi_USaidnet "U.S. Foreign Aid"
lab var wi_EUnet "EU Foreign Aid"

estout EU2 EU1 EU3 US2 US1 US3, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median wi_USaidnet wi_EUnet ) drop(_cons btw_Fmax_civilwar1 $cntrl ) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")




**Table H.9 Alt Capacity models
  
reg F.wi_fh_fog  wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m1
 
reg F.wi_irai_qpa wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m2
 
reg F.wi_kun_ecoabs wi_usa_median   ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m3
 
estout m1 m2 m3 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median ) drop(coldwar wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("") 
 
 
 **Tables H.10 & H.11 Alt Support models
 
reg F.wi_v2stfisccap2   wi_us_EH1995    wi_us_SH1995 wi_v2xcl_prpty ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
  estimates store m4
 
reg wi_v2xcl_prpty  wi_us_EH1995 wi_us_SH1995  ///
 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
  estimates store m5
  
logit Fmax_civilwar1  wi_us_EH1995 wi_us_SH1995   wi_v2stfisccap2 wi_lnpop_wdi btw_Fmax_civilwar1 ///
  wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 
 estimates store m6
 
  
paramed wi_Fv2stfisccap2, avar( wi_us_EH1995 ) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_us_SH1995 wi_onset1 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar )  a0(0)  a1(.40) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med1
 
paramed wi_Fv2stfisccap2, avar( wi_us_SH1995 ) mvar(wi_v2xcl_prpty ) ///
 cvars( wi_us_EH1995 wi_onset1 wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar )  a0(0)  a1(.40) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store med2
 
lab var wi_us_EH1995  "U.S. Economic Hierarchy"
lab var wi_us_SH1995  "U.S. Security Hierarchy"

   
estout m5 m4 m6, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ) ///
stats( r2 N, fmt(%9.2f %9.0f) labels("R-Sq" ))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_us_EH1995    wi_us_SH1995 ) drop(btw_Fmax_civilwar1 wi_v2xcl_prpty coldwar wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("") 
  
estout med1  med2 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.1 ) ///
stats( r2 aic N, fmt(%9.2f %9.1f %9.0f) labels("R-Sq" "AIC"))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order() drop() ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")



**Table I.12 - Adressing Uncertainty in the Protege Measure

use MIdataset, clear
lab var wi_compete "Competition" 
lab var USsignal "US Support"

global cntrl_mi wi_compete  wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 




mi estimate, post:  reg wi_Fv2stfisccap2  USsignal   $cntrl_mi
est sto mi1
mi estimate, post:  reg wi_v2xcl_prpty  USsignal  $cntrl_mi  if wi_Fv2stfisccap2!=.
est sto mi2
mi estimate, post:  reg wi_Fv2stfisccap2  wi_v2xcl_prpty USsignal $cntrl_mi 
est sto mi3

  mi estimate ,  cmdok: paramed wi_Fv2stfisccap2 , avar(USsignal) mvar(wi_v2xcl_prpty ) ///
 cvars( $cntrl_mi )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction 
 estimates store mimed1

mi estimate, cmdok post : ivreg2 wi_Fv2stfisccap2  $cntrl_mi ///
 (USsignal=echelon),  gmm2s  first 
  estimates store miv1
 
mi estimate, cmdok post : ivreg2 wi_v2xcl_prpty  $cntrl_mi ///
 (USsignal=echelon) if wi_Fv2stfisccap2!=., gmm2s first 
  estimates store miv2 

 estout mi1 mi2 mi3 miv1 miv2, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats(  aic N, fmt( %9.1f %9.0f) labels("AIC"))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(USsignal  wi_v2xcl_prpty ) drop(wi_c2 wi_c3  ) ///
mlabels ("Model 1" "Model 2" "Model 3" ) ///
title("")
 
  
**Table I.13 - Replication of Manuscript Table 2 Addressing Uncertainty. 
  
global cwcntrl_mi wi_lnpop_wdi btw_Fmax_civilwar1 wi_lngdppc wi_compete wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar

mi estimate, post:  regress wi_v2stfisccap  USsignal  $cwcntrl_mi , robust
 estimates store mib1


mi estimate, post:  logit Fmax_civilwar1  USsignal wi_v2stfisccap $cwcntrl_mi , robust
 estimates store mib2
 
mi estimate, cmdok:  paramed Fmax_civilwar1, avar(USsignal) mvar(wi_v2stfisccap) ///
 cvars($cwcntrl_mi)  a0(0)  a1(.40) m(0) ///
yreg(logistic) mreg(linear) nointeraction  
  estimates store mimed4 
 
mi estimate, post: regress wi_v2xcl_prpt  USsignal wi_v2stfisccap  $cwcntrl_mi , robust
  estimates store mib3
 
mi estimate, post: logit Fmax_civilwar1  USsignal wi_v2stfisccap  wi_v2xcl_prpt $cwcntrl_mi , robust
 estimates store mib4
 
mi estimate, cmdok:  paramed Fmax_civilwar1, avar(USsignal) mvar(wi_v2xcl_prpt) ///
 cvars($cwcntrl_mi wi_v2stfisccap)  a0(0)  a1(.40) m(0) ///
yreg(logistic) mreg(linear) nointeraction  
  estimates store med5
 
mi estimate, cmdok post : ivreg2 Fmax_civilwar1   $cwcntrl_mi  ///
 (USsignal=echelon),  gmm2s  first 
  estimates store miiv3 

lab var btw_Fmax_civilwar1 "Average Conflict"
lab var wi_compete  "Competition"
 
 estout mib1 mib2 mib3 mib4 miiv3, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats(  aic N, fmt( %9.1f %9.0f) labels("AIC"))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(USsignal  wi_v2xcl_prpty ) drop(wi_c2 wi_c3  ) ///
mlabels ("Model 1" "Model 2" "Model 3" ) ///
title("")
 


** Table J.14 Linear Civil Conflict Model. 
use hierarchy_replication.dta, clear
global cwcntrl wi_lnpop_wdi btw_Fmax_civilwar1 wi_lngdppc wi_compete wi_polity2 wi_polity2_2 wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar
global cntrl wi_compete  wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 

 regress Fmax_civilwar1  wi_usa_median wi_v2stfisccap2 $cwcntrl , robust
 estimates store b2

 paramed Fmax_civilwar1, avar(wi_usa_median) mvar(wi_v2stfisccap2) ///
 cvars($cwcntrl)  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction  
  estimates store med4 
 
 regress Fmax_civilwar1  wi_usa_median  wi_v2xcl_prpt wi_v2stfisccap2 $cwcntrl , robust
 estimates store b4
 
 paramed Fmax_civilwar1, avar(wi_usa_median) mvar(wi_v2xcl_prpt) ///
 cvars($cwcntrl )  a0(0)  a1(1) m(0) ///
yreg(linear) mreg(linear) nointeraction  
  estimates store med5
 
ivreg2 Fmax_civilwar1   $cwcntrl  ///
 (wi_usa_median=echelon),  gmm2s  first 
  estimates store iv3

lab var btw_Fmax_civilwar1 "Average Conflict"
lab var wi_compete  "Competition"
 
       estout  b2  b4 iv3, cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
stats(  aic N, fmt( %9.1f %9.0f) labels("AIC"))  style(tex) ///
legend label collabels(none) varlabels(_cons Constant) ///
order(wi_usa_median  wi_v2xcl_prpty ) drop(wi_c2 wi_c3 ) ///
mlabels ("Model 1" "Model 2" "Model 3"  ) ///
title("")


**Table K.15 Trade
global cntrl wi_compete  wi_lnpop_wdi wi_lngdppc wi_polity2 wi_polity2_2  wi_ny_gdp_totl_rt_zs wi_cwyrs wi_c2 wi_c3 coldwar 

reg F.wi_v2stfisccap2 wi_v2xcl_prpty  wi_usa_median wi_ustrade $cntrl , robust
 estimates store t1

reg F.wi_v2stfisccap2 wi_v2xcl_prpty  wi_usa_median wi_trade_wdi $cntrl , robust 
 estimates store t2

reg F.wi_v2stfisccap2 wi_v2xcl_prpty  wi_usa_median wi_tradetax $cntrl , robust 
 estimates store t3

estout t1 t2 t3 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
 stats(  aic N, fmt( %9.1f %9.0f) labels("AIC")) ///
legend label collabels(none) varlabels(_cons Constant) style(tex) ///
order(wi_usa_median wi_v2xcl_prpty wi_ustrade wi_trade_wdi  wi_tradetax ) drop(_cons  $cntrl ) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")



** Table L.16 - Variance Components Analysis

use coder_val, clear

foreach var of varlist v2stfisccap v2elfrfair v2psparban v2exrescon v2jucomp{ 
di "`var'"

mixed `var'  || country_id: || coder_id:  || year: ,  stddev  
est sto _`var' 
 }

 
 



** Figure L.4 Correlation w/ Bureaucratic Quality
** Figure L.5 - Correlation with Natural Resource Revenue and non-resource revenue

use corr_val, clear
 twoway (scatter  burqual_ic v2stfisccap2, msymbol(x))(lowess burqual_ic v2stfisccap2,  bwidth(0.5)) if v2stfisccap2>-3, name(_`cap', replace) scheme(s1mono) legend(off) ytitle(IRCG bur. quality)
 twoway (scatter  tot_res_rev v2stfisccap2, msymbol(x))(lowess tot_res_rev v2stfisccap2,  bwidth(0.5)) if v2stfisccap2>-3,  scheme(s1mono) legend(off) ytitle("Nat. Resource Revenue / GDP")
 twoway (scatter  grants v2stfisccap2, msymbol(x))(lowess grants v2stfisccap2,  bwidth(0.5)) if v2stfisccap2>-3  ,  scheme(s1mono) legend(off) ytitle("Grants / GDP")
 twoway (scatter  tot_nres_rev_inc_sc v2stfisccap2, msymbol(x))(lowess tot_nres_rev_inc_sc v2stfisccap2,  bwidth(0.5)) if v2stfisccap2>-3 , name(_nnr, replace) scheme(s1mono) legend(off) ytitle(non resource rev. / GDP)





**Figure L.6 -

use hierarchy_replication.dta, clear

gen incdum2 = 0 
replace incdum2 = 1 if indv!=.

logit incdum2 v2stfisccap2

margins, at(v2stfisccap2=(-3.5(.2)2.4)) 

marginsplot, recast(line) recastci(rarea)  xlabel(-3.5(1)2.5) ///
xtitle("V-Dem Capacity") ytitle("Pr(Tax Data)") title("") 

**Figures L.7 

egen moveave1 = filter(usa_median), coef(1 1 1) lags(-3/-1) normalise 
egen moveave2 = filter(indvtax), coef(1 1 1) lags(-3/-1) normalise 

twoway ( tsline F.moveave2 if ccode==355 & year >1990 & year <=2012, yaxis(1) ///
  ytitle("Income Tax (% of Revenue)", axis(1) size(3.5)) xtitle("Year", size(3.5)))  ///
(tsline moveave1 if ccode==355 & year >1990 & year <=2012, ///
yaxis(2) ytitle("U.S. Support", axis(2) size(3.5))), legend(pos(5) ring(0) col(1) ///
lab(1 "Taxes") lab(2 "U.S. Support")) title("Bulgaria")


twoway ( tsline F.moveave2 if ccode==703 & year >1990 & year <=2012, yaxis(1) ///
  ytitle("Income Tax (% of Revenue)", axis(1) size(3.5)) xtitle("Year", size(3.5)))  ///
(tsline moveave1 if ccode==703 & year >1990 & year <=2012, ///
yaxis(2) ytitle("U.S. Support", axis(2) size(3.5))), legend(pos(5) ring(0) col(1) ///
lab(1 "Taxes") lab(2 "U.S. Support")) title("Kyrgyzstan")


**Table L.17

reg  wi_indvtax wi_v2stfisccap2     if usa_median>=  0.38  
estimates store m1a
reg  wi_indvtax wi_v2stfisccap2   if usa_median<   -0.6 
estimates store m2a 
reg  wi_indvtax wi_v2stfisccap2  $cntrl   if usa_median>=  0.38  
estimates store m1
reg  wi_indvtax wi_v2stfisccap2 $cntrl   if usa_median<   -0.6 
estimates store m2


 
 estout m1a m1 m2a m2 , cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) starlevels(* 0.05 ) ///
 stats(  aic N, fmt( %9.1f %9.0f) labels("AIC")) ///
legend label collabels(none) varlabels(_cons Constant) style(tex) ///
order(wi_v2stfisccap2  ) drop(_cons  $cntrl ) ///
mlabels ("Model 1" "Model 2" "Model 3" "Model 4") ///
title("")

